package com.sojson.util.zookeeper;

import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.cache.ChildData;
import org.apache.zookeeper.Watcher;

/**
 * 自定义监听接口
 * 
 * @author liu
 * @date 2021-08-03
 */
public interface CustomWatcher extends Watcher {

    /**
     * 当监控的节点发生变化时触发
     * 
     * @param client
     * @param childData
     * @throws Exception
     */
    void onNodeUpdated(CuratorFramework client, ChildData childData) throws Exception;

    /**
     * 当添加子节点时触发(只监听子节点)
     * 
     * @param client
     * @param childData
     * @throws Exception
     */
    void onChildAdd(CuratorFramework client, ChildData childData) throws Exception;

    /**
     * 当删除子节点时触发(只监听子节点)
     * 
     * @param client
     * @param childData
     * @throws Exception
     */
    void onChildRemove(CuratorFramework client, ChildData childData) throws Exception;

    /**
     * 当修改子节点时触发(只监听子节点)
     * 
     * @param client
     * @param childData
     * @throws Exception
     */
    void onChildUpdate(CuratorFramework client, ChildData childData) throws Exception;

    /**
     * 当添加节点时触发(监听本身和子节点)
     * 
     * @param client
     * @param childData
     * @throws Exception
     */
    void onTreeNodeAdd(CuratorFramework client, ChildData childData) throws Exception;

    /**
     * 当修改节点时触发(监听本身和子节点)
     * 
     * @param client
     * @param childData
     * @throws Exception
     */
    void onTreeNodeUpdated(CuratorFramework client, ChildData childData) throws Exception;

    /**
     * 当删除节点时触发(监听本身和子节点)
     * 
     * @param client
     * @param childData
     * @throws Exception
     */
    void onTreeNodeRemove(CuratorFramework client, ChildData childData) throws Exception;

}